package com.metagurukul.informer.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.metagurukul.informer.utility.ConnectionFactory;

public class ForgotPasswordDAO {

	/**
	 * return the  password for requested member
	 * @param id
	 * @return
	 * @throws SQLException
	 */
	public String getPassword(String id) throws SQLException {

		
		String password=null;
		ResultSet rs = null;
		PreparedStatement ps=null;
		
		Connection con = ConnectionFactory.getInstance();
		String sql = "SELECT * FROM users WHERE id=?";
		ps=con.prepareStatement(sql);
		ps.setString(1, id);
		rs=ps.executeQuery();
			
		if (rs.next()) {
			password=rs.getString(3);
		}

		if(ps!=null){
	   		ps.close();
		}
	   	if(rs!=null) {
	   		rs.close();
	   	}
	   	
		if(con!=null){
			con.close();
		}
		
		return password;
	}
}
